<script setup>
import { useStore } from "@/store";
import { ref } from "vue";
import USwiper from "../../uni_modules/uview-plus/components/u-swiper/u-swiper.vue";
const store = useStore()
const curData = store['getCurData'];
const contentText = curData['noticeContent']?.match(/(?<=<p>)(\d+|[\u4e00-\u9fa5]).*?(?=<\/p>)/g)?.map((v,i)=>`${i===0 ? '<br/>' : ''}${i+1}.${v}<br/><br/>`)?.reduce((prev,cur)=>prev+cur,'')
const swiperList = ref(curData['noticeContent']?.match(/(?<=src=").*?(png|jpg|mp4)/g)?.map(v=>v?.replace(/(\/dev-api|\/prod-api)/g,''))?.map(v=>/(png|jpg)/g.test(v)?`${window.baseURL}${v}`:v)?.sort((v,_)=>/mp4$/g.test(v)?-1:1));
</script>

<template>
  <view class="dynamic content">
    <u-swiper
        :list="swiperList"
        :height="240"
        :autoplay="!swiperList.some(v=>/mp4/g.test(v))"
        :radius="15"
    >

    </u-swiper>
    <view class="title">{{ curData['noticeTitle'] }}</view>
    <view class="text">内容详情</view>
    <rich-text class="contentText" :nodes="contentText"/>
  </view>
</template>

<style scoped lang="scss">
.dynamic{
  width: 100%;
  height: calc(100vh - 44px);
}
</style>